package ru.susu.algebra;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.math.BigInteger;

import ru.susu.algebra.field.quadratic.GeneralUnitFormatter;
import ru.susu.algebra.field.quadratic.QuadraticField;
import ru.susu.algebra.field.quadratic.QuadraticInteger;
import ru.susu.algebra.ui.formatters.IFormatter;
import ru.susu.algebra.util.NumberUtilities;

/**
 * @author akargapolov
 * @since: 18.04.2010
 */
public class GeneralUnitFinder
{
	public static void main(String[] args) throws Exception
	{
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("ExecuteResults/GeneralUnits/units.txt")));
		IFormatter<QuadraticInteger> formatter = new GeneralUnitFormatter();
		for (int i = 2; i <= 101; i++)
		{
			if (NumberUtilities.containsSquare(BigInteger.valueOf(i)))
			{
				continue;
			}
			QuadraticInteger qInteger = new QuadraticInteger(BigInteger.ONE, BigInteger.ONE, BigInteger.valueOf(i));
			QuadraticInteger gUnit = new QuadraticField(qInteger).getGeneralUnit();
			out.println(i + " general unit: " + formatter.format(gUnit));
		}
		out.close();
	}

}
